package com.bao.work;

public class InnerClassTest03 {
    public static void main(String[] args) {
        Receptionist r1 = new Receptionist(u->u.setUserType("V1"));
        Receptionist r2 = new Receptionist(u->u.setUserType("V2"));
        Receptionist r3 = new Receptionist(u->u.setUserType("A"));
        User[] users = new User[15];
        for (int i = 0; i < users.length; i++) {
            users[i]=new User();
            users[i].setId(String.valueOf(i + 1));
        }
        for (int i = 0; i < 5; i++) {
            r1.setUserType(users[i]);
        }
        for (int i = 5; i < 10; i++) {
            r2.setUserType(users[i]);
        }
        for (int i = 9; i < 15; i++) {
            r3.setUserType(users[i]);
        }
        for (User user : users) {
            System.out.println(user.getId()+"-"+user.getUserType());
        }
    }
}

class User {
    private String userType;
    private String id;

    public User() {
    }

    public String getUserType() {
        return userType;
    }

    public void setUserType(String userType) {
        this.userType = userType;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public User(String userType, String id) {
        this.userType = userType;
        this.id = id;
    }
}

interface Filter {
    void filterUser(User u);
}

class Receptionist {
    public Filter filter;

    public Receptionist() {
    }

    public Receptionist(Filter filter) {
        this.filter = filter;
    }

    public Filter getFilter() {
        return filter;
    }

    public void setFilter(Filter filter) {
        this.filter = filter;
    }

    public void setUserType(User u) {
        filter.filterUser(u);
    }
}

